package com.yaorange.web.controller.nongjt;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yaorange.common.annotation.Log;
import com.yaorange.common.core.controller.BaseController;
import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.common.enums.BusinessType;
import com.yaorange.nongjt.domain.NjtSerial;
import com.yaorange.nongjt.service.INjtSerialService;
import com.yaorange.common.utils.poi.ExcelUtil;
import com.yaorange.common.core.page.TableDataInfo;

/**
 * 打印机序列号Controller
 * 
 * @author mudajun
 * @date 2025-03-01
 */
@RestController
@RequestMapping("/nongjt/serial")
public class NjtSerialController extends BaseController
{
    @Autowired
    private INjtSerialService njtSerialService;

    /**
     * 查询打印机序列号列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:serial:list')")
    @GetMapping("/list")
    public TableDataInfo list(NjtSerial njtSerial)
    {
        startPage();
        List<NjtSerial> list = njtSerialService.selectNjtSerialList(njtSerial);
        return getDataTable(list);
    }

    /**
     * 导出打印机序列号列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:serial:export')")
    @Log(title = "打印机序列号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjtSerial njtSerial)
    {
        List<NjtSerial> list = njtSerialService.selectNjtSerialList(njtSerial);
        ExcelUtil<NjtSerial> util = new ExcelUtil<NjtSerial>(NjtSerial.class);
        util.exportExcel(response, list, "打印机序列号数据");
    }

    /**
     * 获取打印机序列号详细信息
     */
    @PreAuthorize("@ss.hasPermi('nongjt:serial:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(njtSerialService.selectNjtSerialById(id));
    }

    /**
     * 新增打印机序列号
     */
    @PreAuthorize("@ss.hasPermi('nongjt:serial:add')")
    @Log(title = "打印机序列号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NjtSerial njtSerial)
    {
        return toAjax(njtSerialService.insertNjtSerial(njtSerial));
    }

    /**
     * 修改打印机序列号
     */
    @PreAuthorize("@ss.hasPermi('nongjt:serial:edit')")
    @Log(title = "打印机序列号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NjtSerial njtSerial)
    {
        return toAjax(njtSerialService.updateNjtSerial(njtSerial));
    }

    /**
     * 删除打印机序列号
     */
    @PreAuthorize("@ss.hasPermi('nongjt:serial:remove')")
    @Log(title = "打印机序列号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(njtSerialService.deleteNjtSerialByIds(ids));
    }
}
